<template>
  <el-dialog :visible.sync="visible"
             title="考核详情"
             width="65%"
             :before-close="modalClose"
             :close-on-click-modal="false"
             :close-on-press-escape="false">
    <div class="padding_20">
      <element-table class="mt-20"
                     :columns="columns"
                     :data="tableData"
                     v-loading="loading"
                     pager
                     :pageTotal="pageTotal"
                     :pageIndex="pageIndex"
                     :pageSize="pageSize"
                     @handleChangePage="handleChangePage">
      </element-table>
    </div>
  </el-dialog>
</template>

<script>
import ElementTable from "../../../../base/ElementTable";

export default {
  name: "statisticsDialog",
  props:{
    dataObj: {
      type: Object,
      default: {}
    },
    visible: {
      type: Boolean,
      default: false
    }
  },
  data(){
    return{
      pageTotal: 0,
      pageIndex: 1,
      pageSize: 20,
      loading:false,
      columns: [
        {
          label: '店员姓名',
          prop: 'nickName',
          align: "center",
          width: 200
        }, {
          label: '参与考核次数',
          prop: 'assessNum',
          align: "center"
        }, {
          label: '考核是否通过',
          prop: 'isValidity',
          align: 'center',
          formatter:(row,cellValue)=>{
            return row.isValidity===1?'是':'否'
          }
        }
      ],
      tableData:[{}]
    }
  },
  created() {
    console.log(this.dataObj)
    this.getList()
  },
  methods:{
    modalClose() {
      this.$emit('update:visible', false); // 直接修改父组件的属性
    },
    getList() {
      this.loading = true
      this.post(this.api.promote.getAssessReportDetail, {
        managementNoticeId: this.dataObj.id,
        hospitalId: this.dataObj.hospitalId,
        pageSize: this.pageSize,
        pageIndex: this.pageIndex - 1,
      }).then((res) => {
        this.loading = false
        if (res.data.code === '200') {
          this.tableData = res.data.object
          this.pageTotal = res.data.totalNum;
        }
      })
    },
    // 分页
    handleChangePage(page) {
      this.pageIndex = page;
      this.getList();
    },
    // 时间转换
    formatterDate(time) {
      if (time)
        return this.commonFunction.timestampFormat(new Date(time), 'yyyy-MM-dd hh:mm')
      else
        return ''
    },
  },
  components: {
    'element-table': ElementTable,
  }
}
</script>

<style scoped>

</style>
